/**
 * Created with IntelliJ IDEA
 * Description
 * User：chenshu
 * Date：2023-10-17
 * Time：22:23
 */
public class People {
    //1.默认初始化
    public String name;
    public int age;
    //2.就地初始化
    /*public String name = "Chenshu";
    public int age = 20;*/

    @Override
    //generate一个toString
    //@...是注解，表示是重写的方法，可用于检测方法名是否和重写方法相同
    public String toString() {
        return "People{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }

    People() {
        //1.只能放在第一行 2.不能形成环 3.只能放在构造函数内
        this("Chenshu", 20);
    }

    People(String name, int age) {
        this.name = name;
        this.age = age;
    }
}

